package com.wwcom.darteagle.model;

public class RunningPercentage {
	private int nDarts;
	private int totalSuccess;
	
	public RunningPercentage () {
		nDarts= 0;
		totalSuccess= 0;
	}
	
	public void addRunningPercentage(RunningPercentage other) {
		this.nDarts+= other.nDarts;
		totalSuccess+= other.totalSuccess;
	}

	public void addDarts(boolean []success) {
		nDarts+= success.length;
		for (boolean s : success) {
			if (s)
				totalSuccess++;
		}
	}
	
	//accessors
	public int getAttempts() {
		return nDarts;
	}
	
	public int getSuccesses() {
		return totalSuccess;
	}

	public void addDarts(boolean success) {
		nDarts++;
		if (success)
			totalSuccess++;
	}

	public float getCurrentPercentage() {
		if (nDarts > 0)
			return ((float)totalSuccess)/((float)nDarts) * 100f;
		return 0.0f;
	}
	
	public void set (int attempts, int successes) {
		nDarts= attempts;
		totalSuccess= successes;
	}
	
}
